package com.zhyt.intelligentpipeline.controller;

import com.zhyt.intelligentpipeline.model.Pipeline;
import com.zhyt.intelligentpipeline.service.StationService;
import com.zhyt.intelligentpipeline.service.TrunkLineService;
import com.zhyt.intelligentpipeline.vo.PipelineWrap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Set;

@RestController
@RequestMapping("trunkLine")
public class TrunkLineController {

    @Resource
    private TrunkLineService trunkLineService;

    @Resource
    private StationService stationService;

    @GetMapping("names")
    public Set<String> getTrunkLineNames(){
        return trunkLineService.getTrunkLineNames();
    }

    @GetMapping("{trunkName}/pipeline")
    public List<PipelineWrap> getTrunkLinePipelines(@PathVariable(name = "trunkName")String trunkName){
        List<Pipeline> pipelines = trunkLineService.getPipelineByTrunkLineName(trunkName);
        return PipelineWrap.convert(pipelines,stationService);
    }
}
